{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox-title">
        <h5>编辑入库记录</h5>
    </div>
    <div class="ibox-content layui-form">
        <div class="layui-row layui-col-space10 layui-form-item ">
            <input type="hidden" name="code_id" value="{$info.code_id}">
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">名称：</label>
                <div class="layui-input-block">
                    <input type="text" name="in_name" lay-verify="required" placeholder="名称" class="layui-input " value="{$info.in_name}">
                </div>
            </div>

            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">缩略图：</label>
                <input type="hidden" name="in_img" id="lay-img" lay-verify="image" value="{$info.in_img}">
                <div class="layui-input-block">
                    <div id="lay-upload">上传图片</div>
                    <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                        预览图：
                        <div class="layui-upload-list" id="lay-list">
                            <img class="layui-append-img" src="{$info.in_img}" onerror="this.src='/static/admin/images/no_img.jpg'">
                        </div>
                    </blockquote>
                </div>
            </div>

            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">仓库：</label>
                <div class="layui-input-block">
                    <select name="warehouse_id" lay-verify="required" lay-search="">
                        <option value="">请选择仓库</option>
                        {if !empty($warehouse)}
                        {foreach name="warehouse" item="vo"}
                        <option value="{$vo.house_id}" {$info.warehouse_id==$vo.house_id?'selected':''}>{$vo.warehouse_name}</option>
                        {/foreach}
                        {/if}
                    </select>
                </div>
            </div>

            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">房屋类型：</label>
                <div class="layui-input-block">
                    <select name="house_type_id" lay-verify="required" lay-search="">
                        <option value="">请选择房屋类型</option>
                        {if !empty($houseType)}
                        {foreach name="houseType" item="vo"}
                        <option value="{$vo.house_type_id}" {$info.house_type_id==$vo.house_type_id?'selected':''}>{$vo.house_type}</option>
                        {/foreach}
                        {/if}
                    </select>
                </div>
            </div>

            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">规格类型：</label>
                <div class="layui-input-block">
                    <select name="spec_type_id" lay-verify="required" lay-search="" lay-filter="spec_type">
                        <option value="">请选择规格类型</option>
                        {if !empty($specType)}
                        {foreach name="specType" item="vo"}
                        <option value="{$vo.spec_type_id}" {$info.spec_type_id==$vo.spec_type_id?'selected':''}>{$vo.spec_type}</option>
                        {/foreach}
                        {/if}
                    </select>
                </div>
            </div>
            <input type="hidden" name="old_num" value="{$info.in_num}">
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">编号：</label>
                <div class="layui-input-block">
                    <input type="text" name="in_num" lay-verify="required" placeholder="" class="layui-input "  value="{$info.in_num}" disabled>
                </div>
            </div>

            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">地址：</label>
                <div class="layui-input-block">
                    <input type="text" class="layui-input" name="in_address" lay-verify="required" placeholder="详细地址" value="{$info.in_address}">
                </div>
            </div>

            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">摘要：</label>
                <div class="layui-input-block">
                    <textarea name="in_abstract" lay-verify="required" placeholder="摘要" class="layui-textarea" maxlength="40">{$info.in_abstract}</textarea>
                </div>
            </div>

            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
                    </button>
                    <button class="layui-btn layui-btn-primary" onclick="history.go(-1)">返回</button>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    wk.uploadImg({size:5,url:"{:url('Upload/uploadLocality')}",domain:"{:http_type()}"});
    var editor = wk.wang({elem:'#LAY_editor'});
    layui.use(['form'], function() {
        var form = layui.form;
        form.verify({
            editor:function(value,item){
                if(editor.txt.html() == '<p><br></p>'){
                    return '请填写内容';
                }
            }
        });
        form.on('submit(component-form-element)', function (data) {
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('warehouseQrCodeEdit')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        wk.success(res.msg,"{:url('Qrcode/index')}")
                    } else {
                        wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\');');
                    }
                }
            })
        });
        //编号
        form.on('select(spec_type)', function(data){
            var spec_id = data.value;
            var old_num = $('input[name="old_num"]').val();
            $.ajax({
                url:'{:url("Qrcode/editNum")}',
                type:'post',
                dataType:'json',
                data:{spec_id:spec_id, old_num:old_num},
                success:function(res){
                    $('input[name="in_num"]').val(res.data)
                },
                error:function (res) {
                }
            })
        });
    });


   
</script>
</body>
</html>